home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 111 / PC Guia 111.iso / Software / Utils / NetObjects Fusion 7.0 / NOF7Trial.exe / data1.cab / Fsi_-_English / PhotoGallery / PhotoGallery.js < prev    next >
Text File  |  2002-06-12  |  62KB  |  2,195 lines

  1.     function settingsDefinition(template, subTemplate, subTemplateText, description, preview, path)
  2.     {
  3.         this.lsMaxWidth = 100;
  4.         this.lsMaxHeight = 100;
  5.         this.lsWidth = 100;
  6.         this.lsHeight = 100;
  7.         this.ptMaxWidth = 100;
  8.         this.ptMaxHeight = 100;
  9.         this.ptWidth = 100;
  10.         this.ptHeight = 100;
  11.         this.quality = 85;
  12.         this.template = template;
  13.         this.subTemplate = subTemplate;
  14.         this.subTemplateText = subTemplateText;
  15.         this.description = description;
  16.         this.preview = preview;
  17.         this.path = path;
  18.         this.currentTemplate = '';
  19.         this.currentSubTemplate = '';
  20.         this.origTemplate = '';
  21.         this.origSubTemplate = '';
  22.         this.templateSettings = '';
  23.         this.titleSet = true;
  24.         this.titleEnabled = true;
  25.         this.titleDeleteRow = false;
  26.         this.borderEnabled = false;
  27.         this.borderColor = 0;
  28.         this.borderWidth = 0;
  29.         this.origBorderColor = 0;
  30.         this.origBorderWidth = 0;
  31.         this.spacingEnabled = false;
  32.         this.horizontalSpacing = 0;
  33.         this.verticalSpacing = 0;
  34.     }
  35.  
  36.     function imageAttributes()
  37.     {
  38.         this.flags = 0;
  39.         this.width = 0;
  40.         this.height = 0;
  41.         this.quality = 0;
  42.         this.format = 'jpg';
  43.     }
  44.  
  45.     function imageAttributesEqual(o1, o2)
  46.     {
  47.         return o1.flags == o2.flags &&
  48.             o1.width == o2.width &&
  49.             o1.height == o2.height &&
  50.             o1.quality == o2.quality &&
  51.             o1.format == o2.format;
  52.     }
  53.  
  54.     function imageObjectAttributes(displayAttributes, indexAttributes)
  55.     {
  56.         this.title = '';
  57.         this.description = '';
  58.         this.image = '';
  59.         this.rotation = 0;
  60.         this.display = displayAttributes;
  61.         this.index = indexAttributes;
  62.     }
  63.  
  64.     function imageAttributesToString(o)
  65.     {
  66.         return '' +
  67.         o.flags + ', ' +
  68.         o.width + ', ' +
  69.         o.height + ', ' +
  70.         o.quality + ', ' +
  71.         o.format;
  72.     }
  73.  
  74.     function imageObjectAttributesToString(o)
  75.     {
  76.         return '' +
  77.         o.title + ', ' +
  78.         o.description + ', ' +
  79.         o.image + ', ' +
  80.         imageAttributesToString(o.displayAttributes) + ', ' +
  81.         imageAttributesToString(o.indexAttributes);
  82.     }
  83.  
  84.     function copyImageAttributes(f, t)
  85.     {
  86.         t.flags = f.flags;
  87.         t.width = f.width;
  88.         t.height = f.height;
  89.         t.quality = f.quality;
  90.         t.format = f.format;
  91.     }
  92.  
  93.     function copyImageObjectAttributes(f, t)
  94.     {
  95.         t.title = f.title;
  96.         t.description = f.description;
  97.         t.image = f.image;
  98.         t.rotation = f.rotation;
  99.         copyImageAttributes(f.index, t.index);
  100.         copyImageAttributes(f.display, t.display);
  101.     }
  102.  
  103.     var fDisplayImage = new imageAttributes();
  104.     var fIndexImage = new imageAttributes();
  105.     var oDisplayImage = new imageAttributes();
  106.     var oIndexImage = new imageAttributes();
  107.     
  108.     var fImage = new imageObjectAttributes(fDisplayImage, fIndexImage);
  109.     var oImage = new imageObjectAttributes(oDisplayImage, oIndexImage);
  110.     var currentImage;
  111.  
  112.     var fIndexSettings;
  113.     var fDisplaySettings;
  114.     var currentSettings;
  115.     var currentTemplateSettings;
  116.  
  117.     var INDEX_IS_TABLE            = 0x00000001;
  118.     var INDEX_INCLUDE_TITLE        = 0x00000002;
  119.     var DISPLAY_LAYOUT_MASK        = 0x0000000f;
  120.     var TABLE_GENERATED_MASK     = 0x00000800;
  121.  
  122.     var numoftabs=3;
  123.     var currentTab = -1;
  124.     var numoftabs1=2;
  125.     var currentTab1 = -1;
  126.     var initialTab1 = 0;
  127.     var app = new ActiveXObject( "FSI.FSIApplication" );
  128.     var app2 = new ActiveXObject( "FSI.FSIApplication2" );
  129.     var theSelection;
  130.     var theTable;
  131.     var selection;
  132.     var indexCatalog;
  133.     var displayCatalog;
  134.     var current = 1;
  135.     var index = -1;
  136.     var indices = new Array();
  137.     var positions = new Array();
  138.     var count = 0;
  139.     var seqChanged = false;
  140.     var isUpdating = false;
  141.     var forceUpdate = false;
  142.     var isValid = false;
  143.     var fFieldName;
  144.     var isInitial = window.dialogArguments;
  145.     var indexModified = false;
  146.     var displayModified = false;
  147.     var listInit = false;
  148.             
  149.     function ListCtrl_OnSelect()
  150.     {
  151.         if (isUpdating || (!forceUpdate && index == FSIListCtrl.Index))
  152.             return;
  153.         updateItem();
  154.         updateTab();
  155.     }
  156.     
  157.     function ListCtrl_OnMove()
  158.     {
  159.         isUpdating = true;
  160.         var from = FSIListCtrl.Index;
  161.         var to = FSIListCtrl.DropIndex;
  162.         var f = indices[from];
  163.         
  164.         if (to > from)
  165.         {
  166.             for (var i = from; i < to - 1; i++)
  167.                 indices[i] = indices[i + 1];
  168.  
  169.             indices[to - 1] = f;
  170.         }
  171.         else
  172.         {
  173.             for (var i = from; i > to; i--)
  174.                 indices[i] = indices[i - 1];
  175.  
  176.             indices[to] = f;
  177.         }
  178.  
  179.         index = to;
  180.         selection.SetIndex(indices[index]);
  181.         FSIListCtrl.Move(from, to);
  182.         seqChanged = true;
  183.         FSIListCtrl.focus();
  184.         isUpdating = false;
  185.     }
  186.     
  187.     function ListCtrl_OnReady()
  188.     {
  189.         listInit = true;
  190.         FSIListCtrl.SetSize(ListCtrl.clientWidth - 2, ListCtrl.clientHeight - 2);
  191.         FSIListCtrl.MoveCursor = true;
  192.         updateCatalog();
  193.         tabshow(initialTab1, false);
  194.     }
  195.     
  196.     function initTemplateCombo(o, path, s)
  197.     {
  198.         var iter = new ActiveXObject('FSI.FSIDirIterator');
  199.         var index = 0;
  200.         var i = 0;
  201.         iter.DefineSearch('.\\PhotoGallery\\' + path, '*');
  202.  
  203.         for (;;)
  204.         {
  205.             var p = iter.GetNext();
  206.             if (!p.length)
  207.                 break;
  208.             var q = p.split('.');
  209.             if (q.length > 1)
  210.             {
  211.                 if (q[q.length - 1].split('\\').length == 1)
  212.                     continue;
  213.             }
  214.             p = p.split('\\');
  215.             p = p[p.length - 1];
  216.             if (s == p)
  217.                 index = i;
  218.             var theOption = document.createElement("OPTION"); 
  219.             o.options.add(theOption); 
  220.             theOption.innerText = p;
  221.             i++;
  222.         }
  223.         o.selectedIndex = index;
  224.     }
  225.         
  226.     function handleInfo(info, settings)
  227.     {
  228.         var s = info.split('\n');
  229.  
  230.         for (var i = 0; i < s.length; i++)
  231.         {
  232.             var p = s[i].split('=');
  233.  
  234.             if (p[0] == 'template')
  235.                 settings.currentTemplate = p[1];
  236.             else if (p[0] == 'subtemplate')
  237.                 settings.currentSubTemplate = p[1];
  238.             else if (p[0] == 'flags')
  239.                 settings.flags = p[1] - 0;
  240.             else if (p[0] == 'width')
  241.                 settings.width = p[1] - 0;
  242.             else if (p[0] == 'height')
  243.                 settings.height = p[1] - 0;
  244.             else if (p[0] == 'quality')
  245.                 settings.quality = p[1] - 0;
  246.             else if (p[0] == 'borderColor')
  247.                 settings.borderColor = p[1] - 0;
  248.             else if (p[0] == 'borderWidth')
  249.                 settings.borderWidth = p[1] - 0;
  250.         }
  251.     }
  252.  
  253.     function init()
  254.     {
  255.         fIndexSettings = new settingsDefinition(template, templateStyle, styleText, indexDescription, indexPreview, 'Thumbnail');
  256.         fDisplaySettings = new settingsDefinition(wrapper, wrapperOptions, wrapperOptionsText, displayDescription, displayPreview, 'Photo');
  257.         theSelection = app.GetCurrentSelection();
  258.         if (!theSelection)
  259.             return;
  260.             
  261.         theTable = theSelection.GetTable();
  262.         indexCatalog = theSelection.GetIndexCatalog();
  263.         displayCatalog = theSelection.GetDisplayCatalog();
  264.         app2.SetDialogTitle('Photo Gallery Properties Editor: ' + theTable.Name);
  265.         selection = app.GetGlobalSelection1();
  266.  
  267.         if ((indexCatalog.Flags & INDEX_IS_TABLE) || window.dialogArguments)
  268.             formatType[1].checked = true;
  269.         else
  270.             formatType[0].checked = true;
  271.  
  272.         handleInfo(indexCatalog.Info, fIndexSettings);
  273.         fIndexSettings.origTemplate = fIndexSettings.currentTemplate;
  274.         fIndexSettings.origSubTemplate = fIndexSettings.currentSubTemplate;
  275.         fIndexSettings.origBorderColor = fIndexSettings.borderColor;
  276.         fIndexSettings.origBorderWidth = fIndexSettings.borderWidth;
  277.         handleInfo(displayCatalog.Info, fDisplaySettings);
  278.         fDisplaySettings.origTemplate = fDisplaySettings.currentTemplate;
  279.         fDisplaySettings.origSubTemplate = fDisplaySettings.currentSubTemplate;
  280.         fDisplaySettings.origBorderColor = fDisplaySettings.borderColor;
  281.         fDisplaySettings.origBorderWidth = fDisplaySettings.borderWidth;
  282.  
  283.         initTemplateCombo(template, 'Thumbnail', fIndexSettings.currentTemplate);
  284.         initTemplateCombo(templateStyle, 'Thumbnail\\' + template.options[template.selectedIndex].innerText + '\\options', fIndexSettings.currentSubTemplate);
  285.         initTemplateCombo(wrapper, 'Photo', fDisplaySettings.currentTemplate);
  286.         initTemplateCombo(wrapperOptions, 'Photo\\' + wrapper.options[wrapper.selectedIndex].innerText + '\\options', fDisplaySettings.currentSubTemplate);
  287.  
  288.         if (indexCatalog.Settings.length)
  289.         {
  290.             updateSettings(indexCatalog.Settings, fIndexSettings);
  291.             fIndexSettings.lsMaxWidth = indexCatalog.LsMaxWidth;
  292.             fIndexSettings.lsMaxHeight = indexCatalog.LsMaxHeight;
  293.             fIndexSettings.lsMinWidth = indexCatalog.LsMinWidth;
  294.             fIndexSettings.lsMinHeight = indexCatalog.LsMinHeight;
  295.             fIndexSettings.lsWidth = indexCatalog.LsWidth;
  296.             fIndexSettings.lsHeight = indexCatalog.LsHeight;
  297.             fIndexSettings.ptMaxWidth = indexCatalog.PtMaxWidth;
  298.             fIndexSettings.ptMaxHeight = indexCatalog.PtMaxHeight;
  299.             fIndexSettings.ptMinWidth = indexCatalog.PtMinWidth;
  300.             fIndexSettings.ptMinHeight = indexCatalog.PtMinHeight;
  301.             fIndexSettings.ptWidth = indexCatalog.PtWidth;
  302.             fIndexSettings.ptHeight = indexCatalog.PtHeight;
  303.             fIndexSettings.horizontalSpacing = indexCatalog.HorizontalSpacing;
  304.             fIndexSettings.verticalSpacing = indexCatalog.VerticalSpacing;
  305.         }
  306.         else
  307.             updateInfo(fIndexSettings);
  308.  
  309.         if (displayCatalog.Settings.length)
  310.         {
  311.             updateSettings(displayCatalog.Settings, fDisplaySettings);
  312.             fDisplaySettings.lsMaxWidth = displayCatalog.LsMaxWidth;
  313.             fDisplaySettings.lsMaxHeight = displayCatalog.LsMaxHeight;
  314.             fDisplaySettings.lsMinWidth = displayCatalog.LsMinWidth;
  315.             fDisplaySettings.lsMinHeight = displayCatalog.LsMinHeight;
  316.             fDisplaySettings.lsWidth = displayCatalog.LsWidth;
  317.             fDisplaySettings.lsHeight = displayCatalog.LsHeight;
  318.             fDisplaySettings.ptMaxWidth = displayCatalog.PtMaxWidth;
  319.             fDisplaySettings.ptMaxHeight = displayCatalog.PtMaxHeight;
  320.             fDisplaySettings.ptMinWidth = displayCatalog.PtMinWidth;
  321.             fDisplaySettings.ptMinHeight = displayCatalog.PtMinHeight;
  322.             fDisplaySettings.ptWidth = displayCatalog.PtWidth;
  323.             fDisplaySettings.ptHeight = displayCatalog.PtHeight;
  324.         }
  325.         else
  326.             updateInfo(fDisplaySettings);
  327.  
  328.         updatePreview(fIndexSettings);
  329.         updatePreview(fDisplaySettings);
  330.  
  331.         fIndexSettings.borderColor = fIndexSettings.origBorderColor;
  332.         fIndexSettings.borderWidth = fIndexSettings.origBorderWidth;
  333.         fDisplaySettings.borderColor = fDisplaySettings.origBorderColor;
  334.         fDisplaySettings.borderWidth = fDisplaySettings.origBorderWidth;
  335.  
  336.         if (templateStyle.options.length)
  337.         {
  338.             colorStyleDiv.className="tabhide";
  339.             templateStyleDiv.className="tabshow";
  340.         }
  341.         else
  342.         {
  343.             templateStyleDiv.className="tabhide";
  344.             
  345.             if (fIndexSettings.borderEnabled)
  346.             {
  347.                 colorStyleDiv.className="tabshow";
  348.                 bordercolorctl.style.backgroundColor = fIndexSettings.borderColor;
  349.                 borderwidth.value = fIndexSettings.borderWidth;
  350.             }
  351.             else
  352.                 colorStyleDiv.className="tabhide";
  353.         }
  354.         
  355.         if (fIndexSettings.spacingEnabled)
  356.         {
  357.             cellSpacingDiv.className="tabshow";
  358.             cellspacing.value = fIndexSettings.horizontalSpacing;
  359.         }
  360.         else
  361.             cellSpacingDiv.className="tabhide";
  362.         
  363.         if (wrapperOptions.options.length)
  364.         {
  365.             displayColorStyleDiv.className="tabhide";
  366.             wrapperOptionsDiv.className="tabshow";
  367.         }
  368.         else
  369.         {
  370.             wrapperOptionsDiv.className="tabhide";
  371.             
  372.             if (fDisplaySettings.borderEnabled)
  373.             {
  374.                 displayColorStyleDiv.className="tabshow";
  375.                 displaybordercolorctl.style.backgroundColor = fDisplaySettings.borderColor;
  376.                 displayborderwidth.value = fDisplaySettings.borderWidth;
  377.             }
  378.             else
  379.                 displayColorStyleDiv.className="tabhide";
  380.         }
  381.  
  382.         fFieldName = theSelection.BannerNameField;
  383.         titleInBanner.checked = fFieldName.length;
  384.  
  385.         updateIndexTab(formatType[1].checked)
  386.         textLink.value = indexCatalog.Name;
  387.         columns.selectedIndex = indexCatalog.ColNo - 1;
  388.         includeTitle.checked = indexCatalog.Flags & INDEX_INCLUDE_TITLE;
  389.         layoutSelect[displayCatalog.Flags & DISPLAY_LAYOUT_MASK].checked = true;
  390.  
  391.         setDialogSize(630, 458);
  392.  
  393.         var theMode = app.GetInstVar('mode') - 0;
  394.         if (window.dialogArguments || (theMode == 1 && (indexCatalog.Flags & INDEX_IS_TABLE) == 0))
  395.             theMode = 0;
  396.         if (theMode < 0)
  397.         {
  398.             initialTab1 = 1;
  399.             theMode = 0;
  400.         }
  401.  
  402.         if (selection)
  403.         {
  404.             selection.SetTable(theTable);
  405.             selection.SetIndex(0);
  406.             imageNo.innerText = selection.Count();
  407.  
  408.             for (var i = 0; i < selection.Count(); i++)
  409.             {
  410.                 var pos = selection.GetField('Position') - 0;
  411.                 positions[count] = pos;
  412.                 var p = count;
  413.                 for (var j = 0; j < count; j++)
  414.                 {
  415.                     if (pos < positions[indices[j]])
  416.                     {
  417.                         p = j;
  418.                         break;
  419.                     }
  420.                 }
  421.                 if (p < count)
  422.                 {
  423.                     for (var j = count; j > p; j--)
  424.                         indices[j] = indices[j - 1];
  425.                 }
  426.                 indices[p] = i;
  427.                 count++;
  428.                 selection.NextRecord();
  429.             }
  430.         }
  431.  
  432.         if (theMode)
  433.             currentSettings = (currentTab1 ? fDisplaySettings : fIndexSettings);
  434.         tabshow(theMode, true);
  435.         if (theMode == 0)
  436.             FSIListCtrl.focus();
  437.     }
  438.     
  439.     function newRollover(imgName,imgFiles)
  440.     {
  441.         if (document.images)
  442.         {
  443.             imgFiles=imgFiles+",";
  444.             imgNo=1;
  445.             while(imgFiles.indexOf(',')>0)
  446.             {
  447.                 imgFile=imgFiles.substring(0,imgFiles.indexOf(','));
  448.                 imgFiles=imgFiles.substring(imgFiles.indexOf(',')+1,imgFiles.length);
  449.                 eval(imgName+"_urc_"+imgNo+"=new Image();");
  450.                 eval(imgName+"_urc_"+imgNo+".src='"+imgFile+"';");
  451.                 imgNo++;
  452.             }
  453.         }
  454.     }
  455.     
  456.     function roll(img,on)
  457.     {
  458.         eval("document.images['"+img+"'].src="+img+"_urc_"+on+".src;");
  459.     }
  460.         
  461.     newRollover("tabimg_1b","../resources/images/tab-right-low.gif,../resources/images/tab-left-hi.gif,../resources/images/pix.gif");
  462.  
  463.     for (i=0;i!=numoftabs;i++) {
  464.         newRollover("tabimg"+i+"a","../resources/images/tab-left-low.gif,../resources/images/tab-right-hi.gif,../resources/images/tab-top-hi.gif");
  465.         newRollover("tabimg"+i+"b","../resources/images/tab-right-low.gif,../resources/images/tab-left-hi.gif,../resources/images/tab-top-hi.gif");
  466.     }
  467.  
  468.     newRollover("tabimg"+numoftabs+"a","../resources/images/tab-left-low.gif,../resources/images/tab-right-hi.gif,../resources/images/pix.gif");
  469.  
  470.     newRollover("tabimg_1b1","../resources/images/tab-right-low.gif,../resources/images/tab-left-hi.gif,../resources/images/pix.gif");
  471.  
  472.     for (i=0;i!=numoftabs1;i++) {
  473.         newRollover("tabimg1"+i+"a","../resources/images/tab-left-low.gif,../resources/images/tab-right-hi.gif,../resources/images/tab-top-hi.gif");
  474.         newRollover("tabimg1"+i+"b","../resources/images/tab-right-low.gif,../resources/images/tab-left-hi.gif,../resources/images/tab-top-hi.gif");
  475.     }
  476.  
  477.     newRollover("tabimg1"+numoftabs1+"a","../resources/images/tab-left-low.gif,../resources/images/tab-right-hi.gif,../resources/images/pix.gif");
  478.  
  479.     function tabshow(tabnum, maintab) 
  480.     {
  481.         var tabno = (maintab ? numoftabs : numoftabs1);
  482.         var s = (maintab ? '' : '1');
  483.         var theTab = (maintab ? currentTab : currentTab1);
  484.         
  485.         if (maintab &&
  486.             ((currentTab == 1 && fIndexSettings.origTemplate != template.options[template.selectedIndex].innerText) ||
  487.             (currentTab == 2 && fDisplaySettings.origTemplate != wrapper.options[wrapper.selectedIndex].innerText)))
  488.         {
  489.             setImageSizeAll();
  490.         }
  491.         
  492.         if (theTab >= 0)
  493.             document.all["tabText"+s+theTab].className="tabStyle";
  494.         document.all["tabText"+s+tabnum].className="tabStyleHl";
  495.  
  496.         // turn all tabs off
  497.         roll("tabimg_1b"+s,3);
  498.         if (maintab)
  499.         {
  500.             document.all["tab_1bot"+s].style.backgroundImage="url('../resources/images/tab-bottom.gif')";
  501.             currentTemplateSettings = (tabnum ? (tabnum == 2 ? fDisplaySettings : fIndexSettings) : null);
  502.         }
  503.         
  504.         for (i=0;i!=tabno;i++) 
  505.         {
  506.             roll("tabimg"+s+i+"a",1);
  507.             roll("tabimg"+s+i+"b",1);
  508.             document.all["tab"+s+i].style.backgroundImage="url('../resources/images/tab-top-low.gif')";
  509.             document.all["tab"+s+i+"bot"].style.backgroundImage="url('../resources/images/tab-bottom.gif')";
  510.             if (maintab)
  511.                 document.all["content"+s+i].className="tabhide";
  512.         }
  513.  
  514.         roll("tabimg"+s+tabno+"a",3);
  515.         document.all["tab"+s+tabno+"bot"].style.backgroundImage="url('../resources/images/tab-bottom.gif')";
  516.  
  517.         // turn on the right tab now...
  518.         
  519.         if (tabnum==0) {
  520.              roll("tabimg_1b"+s,2);
  521.         }
  522.         else {
  523.             roll("tabimg"+s+(tabnum-1)+"b",2);
  524.         }
  525.         roll("tabimg"+s+tabnum+"a",3);
  526.         roll("tabimg"+s+tabnum+"b",3);
  527.         roll("tabimg"+s+(tabnum+1)+"a",2);
  528.         document.all["tab"+s+tabnum].style.backgroundImage="url('../resources/images/tab-top-hi.gif')";
  529.         document.all["tab"+s+tabnum+"bot"].style.backgroundImage="url('../resources/images/pix.gif')";
  530.         if (maintab)
  531.         {
  532.             document.all["content"+s+tabnum].className="tabshow";
  533.             currentTab = tabnum;
  534.             
  535.             if (currentImage && currentTab == 0 && (currentImage.flags & TABLE_GENERATED_MASK) == 0)
  536.                 updateTab();
  537.         }
  538.         else
  539.         {
  540.             getFromTab();
  541.             currentTab1 = tabnum;
  542.             currentImage = (currentTab1 ? fDisplayImage : fIndexImage);
  543.             currentSettings = (currentTab1 ? fDisplaySettings : fIndexSettings);
  544.             updateTab();
  545.         }
  546.     }
  547.  
  548.     function setImageType()
  549.     {
  550.         if (imageType.selectedIndex)
  551.         {
  552.             jpeg.className="tabhide";
  553.             gif.className="tabshow";
  554.             prop.innerText = 'Palette:';
  555.             FSIImage.Quality = colors.selectedIndex + 1;
  556.             FSIImage.Format = 'gif';
  557.             FSIImage.Palette = palette.selectedIndex;
  558.         }
  559.         else    
  560.         {
  561.             gif.className="tabhide";
  562.             jpeg.className="tabshow";
  563.             prop.innerText = 'Quality:';
  564.             FSIImage.Quality = quality.value - 0;
  565.             FSIImage.Format = 'jpg';
  566.             FSIImage.Palette = 0;
  567.         }
  568.  
  569.         displayImage();
  570.     }
  571.  
  572.     function setPalette()
  573.     {
  574.         FSIImage.Palette = palette.selectedIndex;
  575.         displayImage();
  576.     }
  577.  
  578.     function setColors()
  579.     {
  580.         FSIImage.Quality = colors.selectedIndex + 1;
  581.         displayImage();
  582.     }
  583.         
  584.     function getFileName()
  585.     {
  586.         var theName = selection.GetField('Image');
  587.         theName = theName.split('\\');
  588.         return theName[theName.length - 1];
  589.     }
  590.     
  591.     function updateCatalog()
  592.     {
  593.         var column0 = app.GetSystemVar('nof_photoNameSize') - 0;
  594.         var column1 = app.GetSystemVar('nof_photoTitleSize') - 0;
  595.         var speed = app.GetSystemVar('nof_downloadSpeed') - 0;
  596.         
  597.         if (!column0 || !column1)
  598.         {
  599.             column0 = 92;
  600.             column1 = 135;
  601.             speed = 1;
  602.         }
  603.  
  604.         downloadSpeed.selectedIndex = speed;
  605.  
  606.         FSIListCtrl.AddColumn('File Name', column0);
  607.         FSIListCtrl.AddColumn('Title', column1);
  608.  
  609.         if (selection)
  610.         {
  611.             for (var i = 0; i < count; i++)
  612.             {
  613.                 selection.SetIndex(indices[i]);
  614.                 var row = FSIListCtrl.AddRow(getFileName());
  615.                 FSIListCtrl.SetValue(row, 1, selection.GetField('Title'));
  616.             }
  617.  
  618.             if (count)
  619.             {            
  620.                 FSIListCtrl.Index = app.IntArg;
  621.                 selection.SetIndex(indices[app.IntArg]);
  622.                 updateItem();
  623.             }
  624.             else
  625.             {
  626.                 DeleteItem.disabled = true;
  627.                 DeleteAll.disabled = true;
  628.             }
  629.         }
  630.     }
  631.     
  632.     function updateIndex()
  633.     {
  634.         fIndexSettings.origTemplate = fIndexSettings.currentTemplate;
  635.         fIndexSettings.origSubTemplate = fIndexSettings.currentSubTemplate;
  636.         indexCatalog.Info = 
  637.             'length=' + fIndexSettings.length + '\n' +
  638.             'index=' + fIndexSettings.index + '\n' +
  639.             'flags=' + fIndexSettings.flags + '\n' +
  640.             'width=' + fIndexSettings.width + '\n' +
  641.             'height=' + fIndexSettings.height + '\n' +
  642.             'quality=' + fIndexSettings.quality + '\n' +
  643.             'template=' + fIndexSettings.currentTemplate + '\n' +
  644.             'subtemplate=' + fIndexSettings.currentSubTemplate + '\n' +
  645.             'borderColor=' + fIndexSettings.borderColor + '\n' +
  646.             'borderWidth=' + fIndexSettings.borderWidth;
  647.         indexCatalog.Settings = fIndexSettings.templateSettings;
  648.         indexCatalog.LsMaxWidth = fIndexSettings.lsMaxWidth;
  649.         indexCatalog.LsMaxHeight = fIndexSettings.lsMaxHeight;
  650.         indexCatalog.LsMinWidth = fIndexSettings.lsMinWidth;
  651.         indexCatalog.LsMinHeight = fIndexSettings.lsMinHeight;
  652.         indexCatalog.LsWidth = fIndexSettings.lsWidth;
  653.         indexCatalog.LsHeight = fIndexSettings.lsHeight;
  654.         indexCatalog.PtMaxWidth = fIndexSettings.ptMaxWidth;
  655.         indexCatalog.PtMaxHeight = fIndexSettings.ptMaxHeight;
  656.         indexCatalog.PtMinWidth = fIndexSettings.ptMinWidth;
  657.         indexCatalog.PtMinHeight = fIndexSettings.ptMinHeight;
  658.         indexCatalog.PtWidth = fIndexSettings.ptWidth;
  659.         indexCatalog.PtHeight = fIndexSettings.ptHeight;
  660.  
  661.         indexCatalog.HorizontalSpacing = fIndexSettings.horizontalSpacing;
  662.         indexCatalog.VerticalSpacing = fIndexSettings.verticalSpacing;
  663.     }
  664.     
  665.     function checkUpdateIndex()
  666.     {
  667.         if (formatType[1].checked &&
  668.             ((indexCatalog.Flags & INDEX_IS_TABLE) == 0 || 
  669.             fIndexSettings.origTemplate != fIndexSettings.currentTemplate ||
  670.             fIndexSettings.origSubTemplate != fIndexSettings.currentSubTemplate ||
  671.             ((indexCatalog.Flags & INDEX_INCLUDE_TITLE) != 0) != includeTitle.checked) ||
  672.             fIndexSettings.horizontalSpacing != indexCatalog.HorizontalSpacing ||
  673.             fIndexSettings.verticalSpacing != indexCatalog.VerticalSpacing ||
  674.             fIndexSettings.borderColor != fIndexSettings.origBorderColor ||
  675.             fIndexSettings.borderWidth != fIndexSettings.origBorderWidth)
  676.         {
  677.             indexModified = true;
  678.             updateIndex();
  679.             importIndexTable(fIndexSettings.origTemplate != fIndexSettings.currentTemplate || isInitial);
  680.         }
  681.  
  682.         var flags = indexCatalog.Flags;
  683.         
  684.         if (formatType[1].checked)
  685.             flags |= INDEX_IS_TABLE;
  686.         else
  687.             flags &= ~INDEX_IS_TABLE;
  688.         if (includeTitle.checked)
  689.             flags |= INDEX_INCLUDE_TITLE;
  690.         else
  691.             flags &= ~INDEX_INCLUDE_TITLE;
  692.  
  693.         if (indexCatalog.Flags != flags)
  694.         {
  695.             indexModified = true;
  696.             indexCatalog.Flags = flags;
  697.         }
  698.     }
  699.  
  700.     function updateDisplay()
  701.     {
  702.         displayModified = true;
  703.         fDisplaySettings.origTemplate = fDisplaySettings.currentTemplate;
  704.         fDisplaySettings.origSubTemplate = fDisplaySettings.currentSubTemplate;
  705.         displayCatalog.Info = 
  706.             'length=' + fDisplaySettings.length + '\n' +
  707.             'index=' + fDisplaySettings.index + '\n' +
  708.             'flags=' + fDisplaySettings.flags + '\n' +
  709.             'width=' + fDisplaySettings.width + '\n' +
  710.             'height=' + fDisplaySettings.height + '\n' +
  711.             'quality=' + fDisplaySettings.quality + '\n' +
  712.             'template=' + fDisplaySettings.currentTemplate + '\n' +
  713.             'subtemplate=' + fDisplaySettings.currentSubTemplate + '\n' +
  714.             'borderColor=' + fDisplaySettings.borderColor + '\n' +
  715.             'borderWidth=' + fDisplaySettings.borderWidth;
  716.         displayCatalog.Settings = fDisplaySettings.templateSettings;
  717.         displayCatalog.LsMaxWidth = fDisplaySettings.lsMaxWidth;
  718.         displayCatalog.LsMaxHeight = fDisplaySettings.lsMaxHeight;
  719.         displayCatalog.LsMinWidth = fDisplaySettings.lsMinWidth;
  720.         displayCatalog.LsMinHeight = fDisplaySettings.lsMinHeight;
  721.         displayCatalog.LsWidth = fDisplaySettings.lsWidth;
  722.         displayCatalog.LsHeight = fDisplaySettings.lsHeight;
  723.         displayCatalog.PtMaxWidth = fDisplaySettings.ptMaxWidth;
  724.         displayCatalog.PtMaxHeight = fDisplaySettings.ptMaxHeight;
  725.         displayCatalog.PtMinWidth = fDisplaySettings.ptMinWidth;
  726.         displayCatalog.PtMinHeight = fDisplaySettings.ptMinHeight;
  727.         displayCatalog.PtWidth = fDisplaySettings.ptWidth;
  728.         displayCatalog.PtHeight = fDisplaySettings.ptHeight;
  729.     }
  730.  
  731.     function checkUpdateDisplay()
  732.     {
  733.         if (fDisplaySettings.origTemplate != fDisplaySettings.currentTemplate ||
  734.             fDisplaySettings.origSubTemplate != fDisplaySettings.currentSubTemplate ||
  735.             fDisplaySettings.borderColor != fDisplaySettings.origBorderColor ||
  736.             fDisplaySettings.borderWidth != fDisplaySettings.origBorderWidth ||
  737.             isInitial)
  738.         {
  739.             displayModified = true;
  740.             updateDisplay();
  741.             importDisplayTable();
  742.         }
  743.  
  744.         var theLayoutId = 0;
  745.         
  746.         for (var i = 0; i < 7; i++)
  747.         {
  748.             if (layoutSelect[i].checked)
  749.             {
  750.                 theLayoutId = i;
  751.                 break;
  752.             }
  753.         }
  754.  
  755.         if ((displayCatalog.Flags & DISPLAY_LAYOUT_MASK) != theLayoutId || isInitial)
  756.         {
  757.             displayModified = true;
  758.             var path = wrapper.options[wrapper.selectedIndex].innerText;
  759.             var importer = new ActiveXObject('FSI.FSIImporter');
  760.             if (!importer.StartImport('.\\PhotoGallery\\Layout\\layout' + theLayoutId, true))
  761.                 return;
  762.             importer.OpenFile('index.html', false);
  763.             if (importer.NextTag('BODY'))
  764.             {
  765.                 importer.DeleteAttribute('BGCOLOR');
  766.                 importer.DeleteAttribute('BACKGROUND');
  767.                 importer.DeleteAttribute('TEXT');
  768.                 importer.DeleteAttribute('LINK');
  769.                 importer.DeleteAttribute('VLINK');
  770.                 importer.DeleteAttribute('ALINK');
  771.             }
  772.             
  773.             importer.CloseFile();
  774.             importer.ImportObject('index.html', displayCatalog, 3, true);
  775.             importer.DeleteImportDirectory();
  776.             flags = displayCatalog.Flags;
  777.             flags &= ~DISPLAY_LAYOUT_MASK;
  778.             flags |= theLayoutId;
  779.             displayCatalog.Flags = flags;
  780.         }
  781.  
  782.         isInitial = false;
  783.     }
  784.     
  785.     function onClose()
  786.     {
  787.         if (currentTab == 1 && fIndexSettings.origTemplate != template.options[template.selectedIndex].innerText)
  788.         {
  789.             indexModified = true;
  790.             setImageSizeAll();
  791.         }
  792.         
  793.         if (currentTab == 2 && fDisplaySettings.origTemplate != wrapper.options[wrapper.selectedIndex].innerText)
  794.         {
  795.             displayModified = true;
  796.             setImageSizeAll();
  797.         }
  798.  
  799.         save();
  800.         fIndexSettings.currentTemplate = template.options[template.selectedIndex].innerText;
  801.         fIndexSettings.currentSubTemplate = (templateStyle.selectedIndex != -1 ? templateStyle.options[templateStyle.selectedIndex].innerText : '');
  802.         fDisplaySettings.currentTemplate = wrapper.options[wrapper.selectedIndex].innerText;
  803.         fDisplaySettings.currentSubTemplate = (wrapperOptions.selectedIndex != -1 ? wrapperOptions.options[wrapperOptions.selectedIndex].innerText : '');
  804.  
  805.         checkUpdateIndex();
  806.         checkUpdateDisplay();
  807.         
  808.         var fieldName = '';
  809.         if (titleInBanner.checked)
  810.             fieldName = 'Title';
  811.             
  812.         if (fieldName != fFieldName)
  813.         {
  814.             displayModified = true;
  815.             theSelection.BannerNameField = fieldName;
  816.         }
  817.  
  818.         if (indexCatalog.Name != textLink.value)
  819.         {
  820.             indexCatalog.Name = textLink.value;
  821.             indexModified = true;
  822.         }
  823.         
  824.         if (indexCatalog.ColNo != columns.selectedIndex + 1)
  825.         {
  826.             indexModified = true;
  827.             indexCatalog.ColNo = columns.selectedIndex + 1;
  828.         }
  829.                 
  830.         if (seqChanged)
  831.         {
  832.             indexModified = true;
  833.             
  834.             for (var i = 0; i < count; i++)
  835.             {
  836.                 selection.SetIndex(indices[i]);
  837.                 selection.SetField('Position', i);
  838.                 selection.Update();
  839.             }
  840.         }
  841.  
  842.         var flags = 0;
  843.         if (indexModified)
  844.             flags += 1;
  845.         if (displayModified)
  846.             flags += 2;
  847.         app.IntArg = flags;
  848.  
  849.         if (listInit)
  850.         {
  851.             app.SetSystemVar('nof_photoNameSize', FSIListCtrl.GetColumnWidth(0));
  852.             app.SetSystemVar('nof_photoTitleSize', FSIListCtrl.GetColumnWidth(1));
  853.         }
  854.         
  855.         app.SetSystemVar('nof_downloadSpeed', downloadSpeed.selectedIndex);
  856.     }
  857.         
  858.     function add()
  859.     {
  860.         var s = app2.SelectMultipleFiles('');
  861.         if (s.length)
  862.         {
  863.             s = s.split('|');
  864.             var position = count;
  865.         
  866.             for (var i = 0; i < s.length; i++)
  867.             {
  868.                 var path = s[i];
  869.                 var quality;
  870.                 var tnquality;
  871.                 selection.NewRecord();
  872.                 selection.SetField('Position', count);
  873.                 selection.SetField('Image', path);
  874.                 selection.SetField('ImageFlags', 0);
  875.                 selection.SetField('ImageTnFlags', 0);
  876.                 
  877.                 path = path.split('.');
  878.                 if (path.length == 2)
  879.                 {
  880.                     path = path[1].toLowerCase();
  881.                     if (path == 'jpg' || path == 'jpeg')
  882.                     {
  883.                         quality = fDisplaySettings.quality;
  884.                         tnquality = fIndexSettings.quality;
  885.                     }
  886.                     else if (path == 'gif')
  887.                     {
  888.                         quality = 7;
  889.                         tnquality = 7;
  890.                     }
  891.                     else
  892.                     {
  893.                         path = 'jpg';
  894.                         quality = fDisplaySettings.quality;
  895.                         tnquality = fIndexSettings.quality;
  896.                     }
  897.                 }
  898.                 else
  899.                 {
  900.                     path = 'jpg';
  901.                     quality = fDisplaySettings.quality;
  902.                     tnquality = fIndexSettings.quality;
  903.                 }
  904.  
  905.                 selection.SetField('ImageQuality', quality);
  906.                 selection.SetField('ImageTnQuality', tnquality);
  907.                 selection.SetField('ImageFormat', path);
  908.                 selection.SetField('ImageTnFormat', path);
  909.                 selection.Update();
  910.                 
  911.                 var row = FSIListCtrl.AddRow(getFileName());
  912.                 FSIListCtrl.SetValue(row, 1, selection.GetField('Title'));
  913.                 indices[count] = count;
  914.                 count++;
  915.             }
  916.             
  917.             DeleteItem.disabled = (count == 0);
  918.             DeleteAll.disabled = (count == 0);
  919.             if (position)
  920.                 selection.SetIndex(indices[FSIListCtrl.Index]);
  921.             FSIListCtrl.Index = position;
  922.             FSIListCtrl.focus();
  923.             imageNo.innerText = selection.Count();
  924.         }
  925.     }
  926.     
  927.     function deleteItem()
  928.     {
  929.         getFromTab();
  930.         
  931.         if ((fDisplayImage.flags & TABLE_GENERATED_MASK) != 0)
  932.             theSelection.FreeKey(fImage.image, fDisplayImage.width, fDisplayImage.height, fImage.rotation, fDisplayImage.quality, fDisplayImage.format);
  933.  
  934.         if ((fIndexImage.flags & TABLE_GENERATED_MASK) != 0)
  935.             theSelection.FreeKey(fImage.image, fIndexImage.width, fIndexImage.height, fImage.rotation, fIndexImage.quality, fIndexImage.format);
  936.  
  937.         isUpdating = true;
  938.         index = FSIListCtrl.Index;
  939.         selection.SetIndex(indices[index]);
  940.         selection.DeleteRecord();
  941.         selection.Update();
  942.         FSIListCtrl.Delete();
  943.         var removedIndex = indices[index];
  944.         for (var i = index; i < count - 1; i++)
  945.             indices[i] = indices[i + 1];
  946.         for (var i = 0; i < count - 1; i++)
  947.         {
  948.             if (indices[i] > removedIndex)
  949.                 indices[i]--;
  950.         }
  951.         if (index == selection.Count())
  952.             index--;
  953.         FSIListCtrl.Index = index;
  954.         count--;
  955.         seqChanged = true;
  956.         
  957.         if (!count)
  958.         {
  959.             DeleteItem.disabled = true;
  960.             DeleteAll.disabled = true;
  961.         }
  962.         
  963.         imageNo.innerText = selection.Count();
  964.         FSIListCtrl.focus();
  965.         isUpdating = false;
  966.         isValid = false;
  967.         forceUpdate = true;
  968.         updateItem();
  969.         updateTab();
  970.     }
  971.  
  972.     function deleteAll()
  973.     {
  974.         if (!warning('Are you sure you want to remove all the images from the gallery?', 'question', 'nof_qpgremoveall'))
  975.             return;
  976.         getFromTab();
  977.         isUpdating = true;
  978.         FSIListCtrl.Index = 0;
  979.  
  980.         for (var i = count - 1; i >= 0; i--)
  981.         {
  982.             selection.SetIndex(index);
  983.  
  984.             var image = selection.GetField('Image');
  985.             var displayflags = selection.GetField('ImageFlags') - 0;
  986.             var displaywidth = selection.GetField('ImageWidth') - 0;
  987.             var displayheight = selection.GetField('ImageHeight') - 0;
  988.             var rotation = selection.GetField('ImageRotation') - 0;
  989.             var displayquality = selection.GetField('ImageQuality') - 0;
  990.             var displayformat = selection.GetField('ImageFormat');
  991.             var indexflags = selection.GetField('ImageTnFlags') - 0;
  992.             var indexwidth = selection.GetField('ImageTnWidth') - 0;
  993.             var indexheight = selection.GetField('ImageTnHeight') - 0;
  994.             var indexquality = selection.GetField('ImageTnQuality') - 0;
  995.             var indexformat = selection.GetField('ImageTnFormat');
  996.  
  997.             if ((displayflags & TABLE_GENERATED_MASK) != 0)
  998.                 theSelection.FreeKey(image, displaywidth, displayheight, rotation, displayquality, displayformat);
  999.  
  1000.             if ((indexflags & TABLE_GENERATED_MASK) != 0)
  1001.                 theSelection.FreeKey(image, indexwidth, indexheight, rotation, indexquality, indexformat);
  1002.  
  1003.             selection.DeleteRecord();
  1004.             selection.Update();
  1005.             FSIListCtrl.Delete();
  1006.         }
  1007.  
  1008.         seqChanged = true;
  1009.             
  1010.         DeleteItem.disabled = true;
  1011.         DeleteAll.disabled = true;
  1012.     
  1013.         index = -1;
  1014.         count = 0;        
  1015.         imageNo.innerText = 0;
  1016.         FSIListCtrl.focus();
  1017.         isUpdating = false;
  1018.         isValid = false;
  1019.         forceUpdate = true;
  1020.         updateItem();
  1021.         updateTab();
  1022.     }
  1023.  
  1024.     function orientationToValue(i)
  1025.     {
  1026.         switch (i)
  1027.         {
  1028.             case 0:
  1029.                 return 0;
  1030.             case 1:
  1031.                 return 90;
  1032.             case 2:
  1033.                 return 270;
  1034.             default:
  1035.                 return 180;
  1036.         }
  1037.     }
  1038.     
  1039.     function orientationToIndex(v)
  1040.     {
  1041.         switch (v - 0)
  1042.         {
  1043.             case 0:
  1044.                 return 0;
  1045.             case 90:
  1046.                 return 1;
  1047.             case 270:
  1048.                 return 2;
  1049.             default:
  1050.                 return 3;
  1051.         }
  1052.     }
  1053.     
  1054.     function getFromTab()
  1055.     {
  1056.         if (isValid && currentTab1 >= 0)
  1057.         {
  1058.             var theFlags = 0;
  1059.             currentImage.flags = (currentImage.flags & 0xffffff00) | theFlags;
  1060.             currentImage.quality = quality.value - 0;
  1061.             currentImage.format = (imageType.selectedIndex ? 'gif' : 'jpg');
  1062.             
  1063.             if (imageType.selectedIndex)
  1064.                 currentImage.quality = colors.selectedIndex + 1 + 0x10000 * palette.selectedIndex;
  1065.         }
  1066.     }
  1067.     
  1068.     function updateTab()
  1069.     {
  1070.         if (isValid && currentTab1 >= 0)
  1071.         {
  1072.             FSIImage.SwitchImage();
  1073.             var updating = isUpdating;
  1074.             isUpdating = true;
  1075.             var theFlags = currentImage.flags;
  1076.             var isCreated = (theFlags & TABLE_GENERATED_MASK) != 0;
  1077.             FSIImage.IsCreated = isCreated;
  1078.             quality.value = currentImage.quality;
  1079.             updateQuality();
  1080.             imageType.selectedIndex = (currentImage.format == 'gif' ? 1 : 0);
  1081.             if (imageType.selectedIndex)
  1082.             {
  1083.                 jpeg.className="tabhide";
  1084.                 gif.className="tabshow";
  1085.                 prop.innerText = 'Palette:';
  1086.                 palette.selectedIndex = (currentImage.quality & 0xffff0000) / 0x10000;
  1087.                 if (!isCreated && !currentImage.quality)
  1088.                     currentImage.quality = FSIImage.Depth - 1;
  1089.                 colors.selectedIndex = (currentImage.quality & 0xffff) - 1;
  1090.                 FSIImage.Quality = colors.selectedIndex + 1;
  1091.                 FSIImage.Format = 'gif';
  1092.                 FSIImage.Palette = palette.selectedIndex;
  1093.             }
  1094.             else    
  1095.             {
  1096.                 gif.className="tabhide";
  1097.                 jpeg.className="tabshow";
  1098.                 prop.innerText = 'Quality:';
  1099.                 FSIImage.Quality = quality.value - 0;
  1100.                 FSIImage.Format = 'jpg';
  1101.             }
  1102.  
  1103.             if (!isCreated)
  1104.             {
  1105.                 currentImage.flags |= TABLE_GENERATED_MASK;
  1106.                 updateSize();
  1107.             }
  1108.             
  1109.             FSIImage.Width = currentImage.width;
  1110.             FSIImage.Height = currentImage.height;
  1111.             FSIImage.Rotation = orientationToValue(orientation.selectedIndex);
  1112.             isUpdating = updating;
  1113.             displayImage();
  1114.         }
  1115.     }
  1116.  
  1117.     function save()
  1118.     {
  1119.         if (isValid)
  1120.         {
  1121.             var titleIschanged = fImage.title != title.value;
  1122.             var descriptionIsChanged = fImage.description != description.value;
  1123.             fImage.title = title.value;
  1124.             fImage.description = description.value;
  1125.             fImage.rotation = orientationToValue(orientation.selectedIndex);
  1126.  
  1127.             getFromTab();
  1128.             
  1129.             if (titleIschanged)
  1130.             {
  1131.                 selection.SetField('Title', fImage.title);
  1132.                 FSIListCtrl.SetValue(index, 1, title.value);
  1133.                 indexModified = true;
  1134.                 displayModified = true;
  1135.             }
  1136.             
  1137.             if (descriptionIsChanged)
  1138.             {
  1139.                 selection.SetField('Description', fImage.description);
  1140.                 displayModified = true;
  1141.             }
  1142.             
  1143.             if (oImage.rotation != fImage.rotation)
  1144.             {
  1145.                 selection.SetField('ImageRotation', fImage.rotation);
  1146.                 indexModified = true;
  1147.                 displayModified = true;
  1148.             }
  1149.  
  1150.             if (!imageAttributesEqual(oImage.display, fImage.display))
  1151.             {
  1152.                 selection.SetField('ImageFlags', fImage.display.flags);
  1153.                 selection.SetField('ImageWidth', fImage.display.width);
  1154.                 selection.SetField('ImageHeight', fImage.display.height);
  1155.                 selection.SetField('ImageQuality', fImage.display.quality);
  1156.                 selection.SetField('ImageFormat', fImage.display.format);
  1157.                 displayModified = true;
  1158.             }
  1159.  
  1160.             if (!imageAttributesEqual(oImage.index, fImage.index))
  1161.             {
  1162.                 selection.SetField('ImageTnFlags', fImage.index.flags);
  1163.                 selection.SetField('ImageTnWidth', fImage.index.width);
  1164.                 selection.SetField('ImageTnHeight', fImage.index.height);
  1165.                 selection.SetField('ImageTnQuality', fImage.index.quality);
  1166.                 selection.SetField('ImageTnFormat', fImage.index.format);
  1167.                 indexModified = true;
  1168.             }
  1169.         }
  1170.     }
  1171.     
  1172.     function updateItem()
  1173.     {
  1174.         if (isUpdating)
  1175.             return;
  1176.             
  1177.         if (!forceUpdate && index == FSIListCtrl.Index)
  1178.             return;
  1179.  
  1180.         forceUpdate = false;
  1181.         isUpdating = true;
  1182.         
  1183.         if (count == 0)
  1184.         {
  1185.             title.value = '';
  1186.             description.value = '';
  1187.             orientation.selectedIndex = 0;
  1188.             quality.value = 100;
  1189.             updateQuality();
  1190.             FSIImage.Unload();
  1191.             displayImage();
  1192.             isValid = false;
  1193.             isUpdating = false;
  1194.             return;
  1195.         }
  1196.  
  1197.         save();
  1198.                 
  1199.         index = FSIListCtrl.Index;
  1200.         selection.SetIndex(indices[index]);
  1201.  
  1202.         fImage.title = selection.GetField('Title');
  1203.         fImage.description = selection.GetField('Description');
  1204.         fImage.image = selection.GetField('Image');
  1205.         fImage.display.flags = selection.GetField('ImageFlags') - 0;
  1206.         fImage.display.width = selection.GetField('ImageWidth') - 0;
  1207.         fImage.display.height = selection.GetField('ImageHeight') - 0;
  1208.         fImage.rotation = selection.GetField('ImageRotation') - 0;
  1209.         fImage.display.quality = selection.GetField('ImageQuality') - 0;
  1210.         fImage.display.format = selection.GetField('ImageFormat');
  1211.         fImage.index.flags = selection.GetField('ImageTnFlags') - 0;
  1212.         fImage.index.width = selection.GetField('ImageTnWidth') - 0;
  1213.         fImage.index.height = selection.GetField('ImageTnHeight') - 0;
  1214.         fImage.index.quality = selection.GetField('ImageTnQuality') - 0;
  1215.         fImage.index.format = selection.GetField('ImageTnFormat');
  1216.         
  1217.         copyImageObjectAttributes(fImage, oImage);
  1218.  
  1219.         title.value = fImage.title;
  1220.         description.value = fImage.description;
  1221.         orientation.selectedIndex = orientationToIndex(fImage.rotation);
  1222.         FSIImage.Load(fImage.image);
  1223.         
  1224.         isValid = true;
  1225.         isUpdating = false;
  1226.     }
  1227.     
  1228.     function displayImage()
  1229.     {
  1230.         if (isUpdating )
  1231.             return;
  1232.         FSIImage.Display();
  1233.         var w = currentImage.width;
  1234.         var h = currentImage.height;
  1235.         if (w > FSIImage.clientWidth || h > FSIImage.clientHeight)
  1236.         {
  1237.             var ratiox = FSIImage.clientWidth / w;
  1238.             var ratioy = FSIImage.clientHeight / h;
  1239.             var ratio = (ratiox < ratioy ? ratiox : ratioy);
  1240.             ratio = toint(100 * ratio + 0.5);
  1241.             if (ratio < 1)
  1242.                 ratio = 1;
  1243.             else if (ratio > 99)
  1244.                 ratio = 99;
  1245.             previewScale.innerText = '(scaled to ' + ratio + '% to fit)';
  1246.         }
  1247.         else
  1248.             previewScale.innerText = '(actual size)';
  1249.             
  1250.         var theSize = FSIImage.FileSize;
  1251.         var units = '';
  1252.  
  1253.         if (theSize > 1024)
  1254.         {
  1255.             theSize = theSize / 1024;
  1256.             units = ' KB';
  1257.         }
  1258.         if (theSize > 1024)
  1259.         {
  1260.             theSize = theSize / 1024;
  1261.             units = ' MB';
  1262.         }
  1263.         
  1264.         if (units.length)
  1265.         {
  1266.             theSize = '' + theSize;
  1267.             var s = theSize.split('.');
  1268.         
  1269.             theSize = s[0] + '.';
  1270.             if (s.length > 1)
  1271.                 theSize += s[1].substr(0, 1);
  1272.             else
  1273.                 theSize += '0';
  1274.         }
  1275.         
  1276.         fileSize.innerText = 'File Size: ' + theSize + units;
  1277.         updateDownload();
  1278.     }
  1279.  
  1280.     function updateDownload()
  1281.     {
  1282.         var theSize = FSIImage.FileSize;
  1283.         var s;
  1284.  
  1285.         switch (downloadSpeed.selectedIndex)
  1286.         {
  1287.         case 0:
  1288.             s = 28800;
  1289.             break;
  1290.         case 1:
  1291.             s = 56600;
  1292.             break;
  1293.         case 2:
  1294.             s = 128000;
  1295.             break;
  1296.         case 3:
  1297.             s = 384000;
  1298.             break;
  1299.         case 4:
  1300.             s = 512000;
  1301.             break;
  1302.         default:
  1303.             s = 1540000;
  1304.             break;
  1305.         }
  1306.  
  1307.         var t = '' + theSize * 12 / s;
  1308.         t = t.split('.');
  1309.  
  1310.         if (t.length == 1 || t[0].length > 1)
  1311.             t = t[0];
  1312.         else
  1313.             t = t[0] + '.' + t[1].substr(0, 1);
  1314.         
  1315.         if (t == '0.0')
  1316.             t = '0.1';
  1317.  
  1318.         downloadTime.innerText = t;
  1319.     }
  1320.     
  1321.     function spin(o, v, f)
  1322.     {
  1323.         o.value = o.value - 0 + v;
  1324.         f();
  1325.     }
  1326.  
  1327.     function toint(i)
  1328.     {
  1329.         var s = '' + i;
  1330.         return s.split('.')[0] - 0;
  1331.     }
  1332.         
  1333.     function calcProportional()
  1334.     {
  1335.         var w = FSIImage.OrigWidth;
  1336.         var h = FSIImage.OrigHeight;
  1337.  
  1338.         if (orientation.selectedIndex == 1 || orientation.selectedIndex == 2)
  1339.         {
  1340.             var i = w;
  1341.             w = h;
  1342.             h = i;
  1343.         }
  1344.  
  1345.         var maxWidth = currentSettings.lsWidth;
  1346.         var maxHeight = currentSettings.lsHeight;
  1347.  
  1348.         if (w < h && currentSettings.ptWidth && currentSettings.ptHeight)
  1349.         {
  1350.             maxWidth = currentSettings.ptWidth;
  1351.             maxHeight = currentSettings.ptHeight;
  1352.         }
  1353.  
  1354.         var wscale = toint(1000 * w / maxWidth);
  1355.         var hscale = toint(1000 * h / maxHeight);
  1356.         var scale = (wscale > hscale) ? wscale : hscale;
  1357.  
  1358.         if (scale)
  1359.         {
  1360.             currentImage.width = toint(1000 * w / scale);
  1361.             currentImage.height = toint(1000 * h / scale);
  1362.         }
  1363.         else
  1364.         {
  1365.             currentImage.width = 0;
  1366.             currentImage.height = 0;
  1367.         }
  1368.     }
  1369.  
  1370.     function updateSize()
  1371.     {
  1372.         calcProportional();
  1373.  
  1374.         FSIImage.Width = currentImage.width;
  1375.         FSIImage.Height = currentImage.height;
  1376.         displayImage();
  1377.     }
  1378.     
  1379.     function updateQuality()
  1380.     {
  1381.         var q = quality.value - 0;
  1382.  
  1383.         if (isNaN(q))
  1384.         {
  1385.             q = 100;        
  1386.             quality.value = q;
  1387.         }
  1388.         else if (q < 0 || q > 100)
  1389.         {
  1390.             if (q < 0)
  1391.                 q = 0;
  1392.             else
  1393.                 q = 100;
  1394.             
  1395.             quality.value = q;
  1396.         }
  1397.  
  1398.         FSIImage.Quality = q;
  1399.         displayImage();
  1400.         
  1401.         var i = 3;
  1402.         if (q < 40)
  1403.             i = 0;
  1404.         else if (q < 76)
  1405.             i = 1;
  1406.         else if (q < 100)
  1407.             i = 2;
  1408.         
  1409.         if (qualityLevel.selectedIndex != i)
  1410.             qualityLevel.selectedIndex = i;
  1411.     }
  1412.     
  1413.     function setQuality()
  1414.     {
  1415.         var q = 100;
  1416.         
  1417.         switch (qualityLevel.selectedIndex)
  1418.         {
  1419.         case 0:
  1420.             q = 39;
  1421.             break;
  1422.         case 1:
  1423.             q = 75;
  1424.             break;
  1425.         case 2:
  1426.             q = 99;
  1427.             break;
  1428.         default:
  1429.             q = 100;
  1430.             break;
  1431.         }
  1432.         
  1433.         if (quality.value != q)
  1434.         {
  1435.             quality.value = q;
  1436.             updateQuality();
  1437.         }
  1438.     }
  1439.  
  1440.     function setOrientation()
  1441.     {
  1442.         // Clear out information for the other image.
  1443.         var otherImage = (currentTab1 ? fIndexImage : fDisplayImage);
  1444.         var theFlags = otherImage.flags;
  1445.  
  1446.         if ((otherImage.flags & TABLE_GENERATED_MASK) != 0)
  1447.         {
  1448.             theSelection.FreeKey(fImage.image, otherImage.width, otherImage.height, fImage.rotation, otherImage.quality, otherImage.format);
  1449.             otherImage.flags &= ~TABLE_GENERATED_MASK;
  1450.         }
  1451.  
  1452.         fImage.rotation = orientationToValue(orientation.selectedIndex);
  1453.         FSIImage.Rotation = fImage.rotation;
  1454.         updateSize()
  1455.     }
  1456.     
  1457.     function moveUp()
  1458.     {
  1459.         if (count < 2)
  1460.             return;
  1461.             
  1462.         isUpdating = true;
  1463.         index = FSIListCtrl.Index;
  1464.         var i = indices[index];
  1465.         
  1466.         if (index > 0)
  1467.         {
  1468.             indices[index] = indices[index - 1];
  1469.             indices[index - 1] = i;
  1470.             index--;
  1471.         }
  1472.         else
  1473.         {
  1474.             for (var j = 1; j < count; j++)
  1475.                 indices[j - 1] = indices[j];
  1476.  
  1477.             indices[count - 1] = i;
  1478.             index = count - 1;
  1479.         }
  1480.  
  1481.         selection.SetIndex(indices[index]);
  1482.         FSIListCtrl.MoveUp();
  1483.         seqChanged = true;
  1484.         FSIListCtrl.focus();
  1485.         isUpdating = false;
  1486.     }
  1487.  
  1488.     function moveDown()
  1489.     {
  1490.         if (count < 2)
  1491.             return;
  1492.             
  1493.         isUpdating = true;
  1494.         index = FSIListCtrl.Index;
  1495.         var i = indices[index];
  1496.  
  1497.         if (index < count - 1)
  1498.         {
  1499.             indices[index] = indices[index + 1];
  1500.             indices[index + 1] = i;
  1501.             index++;
  1502.         }
  1503.         else
  1504.         {
  1505.             for (var j = count - 1; j > 0; j--)
  1506.                 indices[j] = indices[j - 1];
  1507.  
  1508.             indices[0] = i;
  1509.             index = 0;
  1510.         }
  1511.  
  1512.         FSIListCtrl.MoveDown();
  1513.         seqChanged = true;
  1514.         FSIListCtrl.focus();
  1515.         isUpdating = false;
  1516.     }
  1517.  
  1518.     function selectLayout(i)
  1519.     {
  1520.         layoutSelect[i].click();
  1521.     }
  1522.  
  1523.     function updateIndexTab(isTable)
  1524.     {
  1525.         textLink.disabled = isTable;
  1526.         template.disabled = !isTable;
  1527.         templateStyle.disabled = !isTable;
  1528.         columns.disabled = !isTable;
  1529.         includeTitle.disabled = !fIndexSettings.titleEnabled || !isTable;
  1530.         includeTitleText.disabled = !fIndexSettings.titleEnabled || !isTable;
  1531.         indexFormatTitle.disabled = !fIndexSettings.titleEnabled || !isTable;
  1532.         borderwidth.disabled = !isTable;
  1533.         borderwidthup.disabled = !isTable;
  1534.         borderwidthdown.disabled = !isTable;
  1535.         bordercolorctl.disabled = !isTable;
  1536.         cellspacing.disabled = !isTable;
  1537.         cellspacingup.disabled = !isTable;
  1538.         cellspacingdown.disabled = !isTable;
  1539.         
  1540.         if (fIndexSettings.titleEnabled)
  1541.         {
  1542.             includeTitle.style.visibility = 'visible';
  1543.             includeTitleText.style.visibility = 'visible';
  1544.             indexFormatTitle.style.visibility = 'visible';
  1545.             indexFormatTitleHelp.style.visibility = 'visible';
  1546.         }
  1547.         else
  1548.         {
  1549.             includeTitle.style.visibility = 'hidden';
  1550.             includeTitleText.style.visibility = 'hidden';
  1551.             indexFormatTitle.style.visibility = 'hidden';
  1552.             indexFormatTitleHelp.style.visibility = 'hidden';
  1553.         }
  1554.     }
  1555.  
  1556.     function importIndexTable(overwriteFormat)
  1557.     {
  1558.         var path = template.options[template.selectedIndex].innerText;
  1559.         var importer = new ActiveXObject('FSI.FSIImporter');
  1560.         importer.StartImport('.\\PhotoGallery\\Spacer', true);
  1561.         if (!importer.AddFiles('.\\PhotoGallery\\Thumbnail\\' + path + '\\content', true))
  1562.             return;
  1563.         if (templateStyle.selectedIndex >= 0)
  1564.         {
  1565.             path += '\\options\\' + templateStyle.options[templateStyle.selectedIndex].innerText + '\\content';
  1566.             if (!importer.AddFiles('.\\PhotoGallery\\Thumbnail\\' + path, true))
  1567.                 return;
  1568.         }
  1569.  
  1570.         for (var i = 0; i < 2; i++)
  1571.         {
  1572.             var filename;
  1573.             if (i == 0)
  1574.                 filename = 'index.html';
  1575.             else
  1576.                 filename = 'portrait.html';
  1577.                 
  1578.             if (importer.OpenFile(filename, false))
  1579.             {
  1580.                 if (!includeTitle.checked || fIndexSettings.borderEnabled)
  1581.                 {
  1582.                     if (!includeTitle.checked && importer.NextId('NOFTitle'))
  1583.                     {
  1584.                         var removed = false;
  1585.  
  1586.                         if (fIndexSettings.titleDeleteRow)
  1587.                         {
  1588.                             if (importer.PrevTag('TR') && importer.PrevTag('TR'))
  1589.                             {
  1590.                                 var s = importer.OuterHTML;
  1591.                                 var l = s.length;
  1592.                                 var del = '';
  1593.                                 
  1594.                                 for (var i = 0; i < l; i++)
  1595.                                 {
  1596.                                     if (s.charCodeAt(i) != 13 && s.charCodeAt(i) != 10)
  1597.                                         del += s.charAt(i);
  1598.                                 }
  1599.  
  1600.                                 for (;;)
  1601.                                 {
  1602.                                     if (importer.PrevTag('TABLE'))
  1603.                                     {
  1604.                                         var s = importer.InnerHTML;
  1605.                                         var l = s.length;
  1606.                                         var content = '';
  1607.                                         
  1608.                                         for (var i = 0; i < l; i++)
  1609.                                         {
  1610.                                             if (s.charCodeAt(i) != 13 && s.charCodeAt(i) != 10)
  1611.                                                 content += s.charAt(i);
  1612.                                         }
  1613.  
  1614.                                         var i = content.search(del);
  1615.                                         
  1616.                                         if (i != -1)
  1617.                                         {
  1618.                                             content = content.substr(0, i) + content.substr(i + del.length);
  1619.                                             importer.OuterHTML = content;
  1620.                                             removed = true;
  1621.                                             break;
  1622.                                         }
  1623.                                     }
  1624.                                     else
  1625.                                         break;
  1626.                                 }
  1627.                             }
  1628.                         }
  1629.  
  1630.                         if (!removed)
  1631.                         {
  1632.                             importer.First();
  1633.                             if (importer.NextId('NOFTitle'))
  1634.                                 importer.OuterHTML = '<img height=1 width=1 src="./spacer.gif" vspace=0 hspace=0 border=0>';
  1635.                         }
  1636.                     }
  1637.             
  1638.                     if (fIndexSettings.borderEnabled && importer.First() && importer.NextId('PhotoTable'))
  1639.                     {
  1640.                         importer.SetAttribute('border', fIndexSettings.borderWidth);
  1641.                         importer.SetAttribute('bordercolor', fIndexSettings.borderColor);
  1642.                     }
  1643.                 
  1644.                     importer.First();
  1645.                 }
  1646.  
  1647.                 if (importer.NextTag('BODY'))
  1648.                 {
  1649.                     importer.DeleteAttribute('BGCOLOR');
  1650.                     importer.DeleteAttribute('BACKGROUND');
  1651.                     importer.DeleteAttribute('TEXT');
  1652.                     importer.DeleteAttribute('LINK');
  1653.                     importer.DeleteAttribute('VLINK');
  1654.                     importer.DeleteAttribute('ALINK');
  1655.                 }
  1656.             
  1657.                 importer.CloseFile();
  1658.             }
  1659.         }
  1660.         
  1661.         importer.ImportObject('index.html', indexCatalog, 1, overwriteFormat);
  1662.         importer.ImportObject('portrait.html', indexCatalog, 2, false);
  1663.         importer.DeleteImportDirectory();
  1664.     }
  1665.  
  1666.     function importDisplayTable()
  1667.     {
  1668.         var path = wrapper.options[wrapper.selectedIndex].innerText;
  1669.         var importer = new ActiveXObject('FSI.FSIImporter');
  1670.         if (!importer.StartImport('.\\PhotoGallery\\Photo\\' + path + '\\content', true))
  1671.             return;
  1672.         if (wrapperOptions.selectedIndex >= 0)
  1673.         {
  1674.             path += '\\options\\' + wrapperOptions.options[wrapperOptions.selectedIndex].innerText + '\\content';
  1675.             if (!importer.AddFiles('.\\PhotoGallery\\Photo\\' + path, true))
  1676.                 return;
  1677.         }
  1678.         var importDir = importer.GetImportDirectory(false) + '\\';
  1679.         if (app.DoesFileExist(importDir + 'NavLeft.gif'))
  1680.             displayCatalog.SetFile(1, importDir + 'NavLeft.gif');
  1681.         if (app.DoesFileExist(importDir + 'NavUp.gif'))
  1682.             displayCatalog.SetFile(2, importDir + 'NavUp.gif');
  1683.         if (app.DoesFileExist(importDir + 'NavRight.gif'))
  1684.             displayCatalog.SetFile(3, importDir + 'NavRight.gif');
  1685.             
  1686.         for (var i = 0; i < 2; i++)
  1687.         {
  1688.             var filename;
  1689.             if (i == 0)
  1690.                 filename = 'index.html';
  1691.             else
  1692.                 filename = 'portrait.html';
  1693.                 
  1694.             if (importer.OpenFile(filename, false))
  1695.             {
  1696.                 if (fDisplaySettings.borderEnabled)
  1697.                 {
  1698.                     if (importer.NextId('PhotoTable'))
  1699.                     {
  1700.                         importer.SetAttribute('border', fDisplaySettings.borderWidth);
  1701.                         importer.SetAttribute('bordercolor', fDisplaySettings.borderColor);
  1702.                     }
  1703.                 
  1704.                     importer.First();
  1705.                 }
  1706.  
  1707.                 if (importer.NextTag('BODY'))
  1708.                 {
  1709.                     importer.DeleteAttribute('BGCOLOR');
  1710.                     importer.DeleteAttribute('BACKGROUND');
  1711.                     importer.DeleteAttribute('TEXT');
  1712.                     importer.DeleteAttribute('LINK');
  1713.                     importer.DeleteAttribute('VLINK');
  1714.                     importer.DeleteAttribute('ALINK');
  1715.                 }
  1716.             
  1717.                 importer.CloseFile();
  1718.             }
  1719.         }
  1720.         
  1721.         importer.ImportObject('index.html', displayCatalog, 1, false);
  1722.         importer.ImportObject('portrait.html', displayCatalog, 2, false);
  1723.         importer.DeleteImportDirectory();
  1724.     }
  1725.  
  1726.     function updateTemplate()
  1727.     {
  1728.         for (var i = currentTemplateSettings.subTemplate.options.length - 1; i >= 0; i--)
  1729.             currentTemplateSettings.subTemplate.options.remove(i);
  1730.  
  1731.         initTemplateCombo(currentTemplateSettings.subTemplate, currentTemplateSettings.path + '\\' + currentTemplateSettings.template.options[currentTemplateSettings.template.selectedIndex].innerText + '\\options', '');
  1732.         
  1733.         currentTemplateSettings.currentTemplate = currentTemplateSettings.template.options[currentTemplateSettings.template.selectedIndex].innerText;
  1734.         currentTemplateSettings.currentSubTemplate = (currentTemplateSettings.subTemplate.options.length ? 
  1735.                                                         currentTemplateSettings.subTemplate.options[currentTemplateSettings.subTemplate.selectedIndex].innerText :
  1736.                                                         '');
  1737.  
  1738.         updateStyle(currentTemplateSettings);
  1739.  
  1740.         if (currentTemplateSettings == fIndexSettings)
  1741.         {
  1742.             if (currentTemplateSettings.subTemplate.options.length)
  1743.                 templateStyleDiv.className="tabshow";
  1744.             else
  1745.                 templateStyleDiv.className="tabhide";
  1746.  
  1747.             includeTitle.disabled = !fIndexSettings.titleEnabled;
  1748.             includeTitleText.disabled = !fIndexSettings.titleEnabled;
  1749.             includeTitle.checked = fIndexSettings.titleSet;
  1750.             indexFormatTitle.disabled = !fIndexSettings.titleEnabled;
  1751.  
  1752.             if (fIndexSettings.titleEnabled)
  1753.             {
  1754.                 includeTitle.style.visibility = 'visible';
  1755.                 includeTitleText.style.visibility = 'visible';
  1756.                 indexFormatTitle.style.visibility = 'visible';
  1757.                 indexFormatTitleHelp.style.visibility = 'visible';
  1758.             }
  1759.             else
  1760.             {
  1761.                 includeTitle.style.visibility = 'hidden';
  1762.                 includeTitleText.style.visibility = 'hidden';
  1763.                 indexFormatTitle.style.visibility = 'hidden';
  1764.                 indexFormatTitleHelp.style.visibility = 'hidden';
  1765.             }
  1766.  
  1767.             if (!currentTemplateSettings.subTemplate.options.length)
  1768.             {
  1769.                 if (fIndexSettings.borderEnabled)
  1770.                 {
  1771.                     colorStyleDiv.className="tabshow";
  1772.                     bordercolorctl.style.backgroundColor = fIndexSettings.borderColor;
  1773.                     borderwidth.value = fIndexSettings.borderWidth;
  1774.                 }
  1775.                 else
  1776.                     colorStyleDiv.className="tabhide";
  1777.             }
  1778.             else
  1779.                 colorStyleDiv.className="tabhide";
  1780.         
  1781.             if (fIndexSettings.spacingEnabled)
  1782.             {
  1783.                 cellSpacingDiv.className="tabshow";
  1784.                 cellspacing.value = fIndexSettings.horizontalSpacing;
  1785.             }
  1786.             else
  1787.                 cellSpacingDiv.className="tabhide";
  1788.         }
  1789.         
  1790.         if (currentTemplateSettings == fDisplaySettings)
  1791.         {
  1792.             if (wrapperOptions.options.length)
  1793.             {
  1794.                 displayColorStyleDiv.className="tabhide";
  1795.                 wrapperOptionsDiv.className="tabshow";
  1796.             }
  1797.             else
  1798.             {
  1799.                 wrapperOptionsDiv.className="tabhide";
  1800.                 
  1801.                 if (fDisplaySettings.borderEnabled)
  1802.                 {
  1803.                     displayColorStyleDiv.className="tabshow";
  1804.                     displaybordercolorctl.style.backgroundColor = fDisplaySettings.borderColor;
  1805.                     displayborderwidth.value = fDisplaySettings.borderWidth;
  1806.                 }
  1807.                 else
  1808.                     displayColorStyleDiv.className="tabhide";
  1809.             }
  1810.         }
  1811.  
  1812.         if (currentTemplateSettings.subTemplate.options.length)
  1813.             currentTemplateSettings.subTemplate.selectedIndex = 0;
  1814.     }
  1815.  
  1816.     function updateStyle(settings)
  1817.     {
  1818.         updateInfo(settings);
  1819.         updatePreview(settings);
  1820.     }
  1821.     
  1822.     function updateInfo(settings)
  1823.     {
  1824.         var path = './PhotoGallery/' + settings.path + '/' + settings.template.options[settings.template.selectedIndex].innerText;
  1825.         var optpath = settings.subTemplate.selectedIndex >= 0 ? '/options/' + settings.subTemplate.options[settings.subTemplate.selectedIndex].innerText : '';
  1826.         
  1827.         if (app.DoesFileExist(path + optpath + '/info.txt'))
  1828.             updateSettings(app2.ReadFile(path + optpath + '/info.txt'), settings);
  1829.         else
  1830.             updateSettings(app2.ReadFile(path + '/info.txt'), settings);
  1831.     }
  1832.     
  1833.     function updatePreview(settings)
  1834.     {
  1835.         var path = settings.path + '/' + 
  1836.                     settings.template.options[settings.template.selectedIndex].innerText +
  1837.                     (settings.subTemplate.selectedIndex >= 0 ? '/options/' + settings.subTemplate.options[settings.subTemplate.selectedIndex].innerText : '') +
  1838.                     '/preview.jpg';
  1839.  
  1840.         settings.preview.src = (app.DoesFileExist('./PhotoGallery/' + path) ? './' + path : './../resources/images/clearpixel.gif');
  1841.     }
  1842.  
  1843.     function updateSettings(s, settings)
  1844.     {
  1845.         var description = '';
  1846.         settings.templateSettings = s;
  1847.         settings.titleSet = true;
  1848.         settings.titleEnabled = true;
  1849.         settings.titleDeleteRow = false;
  1850.         settings.lsMaxWidth = 2048;
  1851.         settings.lsMaxHeight = 2048;
  1852.         settings.lsMinWidth = 0;
  1853.         settings.lsMinHeight = 0;
  1854.         settings.lsWidth = 0;
  1855.         settings.lsHeight = 0;
  1856.         settings.ptMaxWidth = 0;
  1857.         settings.ptMaxHeight = 0;
  1858.         settings.ptMinWidth = 0;
  1859.         settings.ptMinHeight = 0;
  1860.         settings.ptWidth = 0;
  1861.         settings.ptHeight = 0;
  1862.         settings.borderEnabled = false;
  1863.         settings.borderColor = 0;
  1864.         settings.borderWidth = 0;
  1865.         settings.spacingEnabled = false;
  1866.         settings.horizontalSpacing = 0;
  1867.         settings.verticalSpacing = 0;
  1868.         s = s.split('\n');
  1869.         for (var i = 0; i < s.length; i++)
  1870.         {
  1871.             var p = s[i].split(',');
  1872.             if (p[0] == 'description')
  1873.             {
  1874.                 description = '';
  1875.                 
  1876.                 if (p.length > 1)
  1877.                     description = p[1];
  1878.                     
  1879.                 for (var j = 2; j < p.length; j++)
  1880.                     description += ',' + p[j];
  1881.             }
  1882.             else if (p[0] == 'landscape')
  1883.             {
  1884.                 var maxWidth = 2048;
  1885.                 var maxHeight = 2048;
  1886.                 var minWidth = 0;
  1887.                 var minHeight = 0;
  1888.                 var width = 0;
  1889.                 var height = 0;
  1890.  
  1891.                 for (var j = 1; j < p.length; j++)
  1892.                 {
  1893.                     var size = p[j].split('=');
  1894.  
  1895.                     if (size.length != 2)
  1896.                         continue;
  1897.                     if (size[0] == 'maxwidth')
  1898.                         maxWidth = size[1] - 0;
  1899.                     else if (size[0] == 'maxheight')
  1900.                         maxHeight = size[1] - 0;
  1901.                     else if (size[0] == 'minwidth')
  1902.                         minWidth = size[1] - 0;
  1903.                     else if (size[0] == 'minheight')
  1904.                         minHeight = size[1] - 0;
  1905.                     else if (size[0] == 'width')
  1906.                         width = size[1] - 0;
  1907.                     else if (size[0] == 'height')
  1908.                         height = size[1] - 0;
  1909.                 }
  1910.  
  1911.                 settings.lsMaxWidth = maxWidth;
  1912.                 settings.lsMaxHeight = maxHeight;
  1913.                 settings.lsMinWidth = minWidth;
  1914.                 settings.lsMinHeight = minHeight;
  1915.                 settings.lsWidth = width;
  1916.                 settings.lsHeight = height;
  1917.             }
  1918.             else if (p[0] == 'portrait')
  1919.             {
  1920.                 var maxWidth = 2048;
  1921.                 var maxHeight = 2048;
  1922.                 var minWidth = 0;
  1923.                 var minHeight = 0;
  1924.                 var width = 0;
  1925.                 var height = 0;
  1926.  
  1927.                 for (var j = 1; j < p.length; j++)
  1928.                 {
  1929.                     var size = p[j].split('=');
  1930.  
  1931.                     if (size.length != 2)
  1932.                         continue;
  1933.                     if (size[0] == 'maxwidth')
  1934.                         maxWidth = size[1] - 0;
  1935.                     else if (size[0] == 'maxheight')
  1936.                         maxHeight = size[1] - 0;
  1937.                     else if (size[0] == 'minwidth')
  1938.                         minWidth = size[1] - 0;
  1939.                     else if (size[0] == 'minheight')
  1940.                         minHeight = size[1] - 0;
  1941.                     else if (size[0] == 'width')
  1942.                         width = size[1] - 0;
  1943.                     else if (size[0] == 'height')
  1944.                         height = size[1] - 0;
  1945.                 }
  1946.  
  1947.                 settings.ptMaxWidth = maxWidth;
  1948.                 settings.ptMaxHeight = maxHeight;
  1949.                 settings.ptMinWidth = minWidth;
  1950.                 settings.ptMinHeight = minHeight;
  1951.                 settings.ptWidth = width;
  1952.                 settings.ptHeight = height;
  1953.             }
  1954.             else if (p[0] == 'title')
  1955.             {
  1956.                 for (var j = 1; j < p.length; j++)
  1957.                 {
  1958.                     var title = p[j].split('=');
  1959.  
  1960.                     if (title.length != 2)
  1961.                         continue;
  1962.                     if (title[0] == 'set')
  1963.                         settings.titleSet = title[1] == 'true';
  1964.                     else if (title[0] == 'enabled')
  1965.                         settings.titleEnabled = title[1] == 'true';
  1966.                     else if (title[0] == 'delete')
  1967.                         settings.titleDeleteRow = title[1] == 'row';
  1968.                 }
  1969.             }
  1970.             else if (p[0] == 'border')
  1971.             {
  1972.                 for (var j = 1; j < p.length; j++)
  1973.                 {
  1974.                     var opt = p[j].split('=');
  1975.  
  1976.                     if (opt.length != 2)
  1977.                         continue;
  1978.                     if (opt[0] == 'color')
  1979.                         settings.borderColor = opt[1] - 0;
  1980.                     else if (opt[0] == 'width')
  1981.                         settings.borderWidth = opt[1] - 0;
  1982.                     else if (opt[0] == 'enabled')
  1983.                         settings.borderEnabled = opt[1] == 'true';
  1984.                 }
  1985.             }
  1986.             else if (p[0] == 'spacing')
  1987.             {
  1988.                 for (var j = 1; j < p.length; j++)
  1989.                 {
  1990.                     var opt = p[j].split('=');
  1991.  
  1992.                     if (opt.length != 2)
  1993.                         continue;
  1994.                     if (opt[0] == 'size')
  1995.                     {
  1996.                         settings.horizontalSpacing = opt[1] - 0;
  1997.                         settings.verticalSpacing = opt[1] - 0;
  1998.                     }
  1999.                     else if (opt[0] == 'width')
  2000.                         settings.horizontalSpacing = opt[1] - 0;
  2001.                     else if (opt[0] == 'height')
  2002.                         settings.verticalSpacing = opt[1] - 0;
  2003.                     else if (opt[0] == 'enabled')
  2004.                         settings.spacingEnabled = opt[1] == 'true';
  2005.                 }
  2006.             }
  2007.         }
  2008.  
  2009.         settings.quality = 85;
  2010.         settings.description.location = description;
  2011.     }
  2012.     
  2013.     function format(field, catalog)
  2014.     {
  2015.         if (catalog == indexCatalog)
  2016.         {
  2017.             indexModified = true;
  2018.             checkUpdateIndex();
  2019.         }
  2020.         else
  2021.         {
  2022.             displayModified = true;
  2023.             checkUpdateDisplay();
  2024.         }
  2025.         catalog.EditFormat(theSelection, 1, field);
  2026.     }
  2027.     
  2028.     function oncaption()
  2029.     {
  2030.         if (!window.dialogArguments && fImage.description.length && fImage.description == description.value)
  2031.             message('If you edit a caption in the Properties editor, any formatting you might have applied to the caption on the photo page is lost.', 'info', 'nof_qpgchangecaption', 8);
  2032.     }
  2033.                 
  2034.     function applyToAll()
  2035.     {
  2036.         var sub = (currentTab1 ? '' : 'Tn');
  2037.         getFromTab();
  2038.  
  2039.         for (var i = 0; i < count; i++)
  2040.         {
  2041.             if (i == index)
  2042.                 continue;
  2043.  
  2044.             selection.SetIndex(indices[i]);
  2045.             var image = selection.GetField('Image');
  2046.             var rotation = selection.GetField('ImageRotation') - 0;
  2047.             var flags = selection.GetField('Image' + sub + 'Flags') - 0;
  2048.             var quality = selection.GetField('Image' + sub + 'Quality') - 0;
  2049.             var format = selection.GetField('Image' + sub + 'Format').toLowerCase();
  2050.  
  2051.             if (format != currentImage.format || quality != currentImage.quality)
  2052.             {
  2053.                 selection.SetField('Image' + sub + 'Quality', currentImage.quality);
  2054.                 selection.SetField('Image' + sub + 'Format', currentImage.format);
  2055.  
  2056.                 if ((flags & TABLE_GENERATED_MASK) != 0)
  2057.                 {
  2058.                     var width = selection.GetField('Image' + sub + 'Width') - 0;
  2059.                     var height = selection.GetField('Image' + sub + 'Height') - 0;
  2060.                     theSelection.FreeKey(image, width, height, rotation, quality, format);
  2061.                     flags &= ~TABLE_GENERATED_MASK;
  2062.                     selection.SetField('Image' + sub + 'Flags', flags);
  2063.                 }
  2064.             }
  2065.         }
  2066.  
  2067.         selection.SetIndex(indices[index]);
  2068.     }
  2069.         
  2070.     function setImageSizeAll()
  2071.     {
  2072.         var sub = (currentTab == 2 ? '' : 'Tn');
  2073.         getFromTab();
  2074.  
  2075.         for (var i = 0; i < count; i++)
  2076.         {
  2077.             selection.SetIndex(indices[i]);
  2078.             var flags = selection.GetField('Image' + sub + 'Flags') - 0;
  2079.  
  2080.             if ((flags & TABLE_GENERATED_MASK) != 0)
  2081.             {
  2082.                 var w = selection.GetField('Image' + sub + 'Width') - 0;
  2083.                 var h = selection.GetField('Image' + sub + 'Height') - 0;
  2084.  
  2085.                 var maxWidth = currentSettings.lsWidth;
  2086.                 var maxHeight = currentSettings.lsHeight;
  2087.  
  2088.                 if (w < h && currentSettings.ptWidth && currentSettings.ptHeight)
  2089.                 {
  2090.                     maxWidth = currentSettings.ptWidth;
  2091.                     maxHeight = currentSettings.ptHeight;
  2092.                 }
  2093.  
  2094.                 var wscale = toint(1000 * w / maxWidth);
  2095.                 var hscale = toint(1000 * h / maxHeight);
  2096.                 var scale = (wscale > hscale ? wscale : hscale);
  2097.  
  2098.                 if (scale != 1000)
  2099.                 {
  2100.                     var image = selection.GetField('Image');
  2101.                     var rotation = selection.GetField('ImageRotation') - 0;
  2102.                     var quality = selection.GetField('Image' + sub + 'Quality') - 0;
  2103.                     var format = selection.GetField('Image' + sub + 'Format').toLowerCase();
  2104.  
  2105.                     theSelection.FreeKey(image, w, h, rotation, quality, format);
  2106.                     flags &= ~TABLE_GENERATED_MASK;
  2107.                     selection.SetField('Image' + sub + 'Flags', flags);
  2108.                 }
  2109.  
  2110.                 if (i == index)
  2111.                 {
  2112.                     if (currentTab == 2)
  2113.                         fDisplayImage.flags = flags;
  2114.                     else
  2115.                         fIndexImage.flags = flags;
  2116.                 }
  2117.             }
  2118.         }
  2119.  
  2120.         selection.SetIndex(indices[index]);
  2121.     }
  2122.  
  2123.     function selectColor(o)
  2124.     {
  2125.         var color = app2.SelectNewColor(fIndexSettings.borderColor);
  2126.         if (color != 0xffffffff)
  2127.         {
  2128.             o.style.backgroundColor = color;
  2129.             fIndexSettings.borderColor = color;
  2130.         }
  2131.     }
  2132.         
  2133.     function updateBorderWidth()
  2134.     {
  2135.         var w = borderwidth.value - 0;
  2136.         if (isNaN(w))
  2137.             w = 0;
  2138.         else if (w < 0)
  2139.             w = 0;
  2140.         else if (w > 1000)
  2141.             w = 1000;
  2142.          
  2143.         borderwidth.value = w;
  2144.         fIndexSettings.borderWidth = w;
  2145.     }
  2146.     
  2147.     function updateCellSpacing()
  2148.     {
  2149.         var w = cellspacing.value - 0;
  2150.         if (isNaN(w))
  2151.             w = 0;
  2152.         else if (w < 0)
  2153.             w = 0;
  2154.         else if (w > 10000)
  2155.             w = 10000;
  2156.             
  2157.         cellspacing.value = w;
  2158.         fIndexSettings.horizontalSpacing = w;
  2159.         fIndexSettings.verticalSpacing = w;
  2160.     }
  2161.     
  2162.     function selectDisplayColor(o)
  2163.     {
  2164.         var color = app2.SelectNewColor(fDisplaySettings.borderColor);
  2165.         if (color != 0xffffffff)
  2166.         {
  2167.             o.style.backgroundColor = color;
  2168.             fDisplaySettings.borderColor = color;
  2169.         }
  2170.     }
  2171.         
  2172.     function updateDisplayBorderWidth()
  2173.     {
  2174.         var w = displayborderwidth.value - 0;
  2175.         if (isNaN(w))
  2176.             w = 0;
  2177.         else if (w < 0)
  2178.             w = 0;
  2179.         else if (w > 1000)
  2180.             w = 1000;
  2181.          
  2182.         displayborderwidth.value = w;
  2183.         fDisplaySettings.borderWidth = w;
  2184.     }
  2185.  
  2186.     function helpFormat(o)
  2187.     {
  2188.         var oPopup = window.createPopup();
  2189.         var oPopBody = oPopup.document.body;
  2190.         oPopBody.style.backgroundColor = "lightyellow";
  2191.         oPopBody.style.border = "solid black 1px";
  2192.         oPopBody.innerHTML = "<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\" width=\"100%\" height=\"100%\"><tr><td><font face='MS Sans Serif' size='-2'><b>Note:</b> If you specify formats and they do not appear in the text, it could be caused by the text style definitions, usually the definition of the Body and Normal(P) tags in the SiteStyle. For example, if the Body tag defines the font size, that definition overrides any font size you specify in the Object Format dialog. You can get around this by choosing a SiteStyle that does not define the property you want to set, or by formatting the individual photo titles.</font></td></tr></table>";
  2193.         oPopup.show(-150, 10, 300 * app2.LogPixelsX / 96, 135 * app2.LogPixelsY / 96, o);
  2194.     }
  2195.